<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: a479655315
  Date: 2019/9/2
  Time: 14:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <link rel="icon" type="image/png" href="${pageContext.request.contextPath}/images/favicon.ico">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>

    <title>个人信息</title>

    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport'/>
    <meta name="viewport" content="width=device-width"/>


    <!-- Bootstrap core CSS     -->
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet"/>

    <!-- Animation library for notifications   -->
    <link href="${pageContext.request.contextPath}/css/animate.min.css" rel="stylesheet"/>

    <!--  Light Bootstrap Table core CSS    -->
    <link href="${pageContext.request.contextPath}/css/light-bootstrap-dashboard.css" rel="stylesheet"/>


    <!--  CSS for Demo Purpose, don't include it in your project     -->
    <link href="${pageContext.request.contextPath}/css/demo.css" rel="stylesheet"/>


    <!--     Fonts and icons     -->
    <link href="${pageContext.request.contextPath}/css/pe-icon-7-stroke.css" rel="stylesheet"/>

    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.10.2.js"></script>
    <script>
        function checkMyInfoForm() {
            var oldpassword = $("#oldpassword").val()
            if(oldpassword != ${user.password}){
                alert("原密码输入错误，请重新输入！")
                return false
            }
            if($("#password").val() != $("#repassword").val()){
                alert("两次密码输入不一致，请检查后提交！")
                return false;
            }
            return true;
        }
    </script>
</head>
<body>

<div class="wrapper">


    <!-- 左侧导航 -->
    <%@include file="include/left.jsp" %>

    <div class="main-panel">

        <!-- nav -->
        <%@include file="include/nav.jsp" %>

        <div class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-8">
                        <div class="card">
                            <div class="header">
                                <h4 class="title">个人信息</h4>
                            </div>
                            <div class="content">
                                <form action="${pageContext.request.contextPath}/user/updateMyInfo.html" method="post" onsubmit="return checkMyInfoForm()">
                                    <input type="hidden" name="id" value="${user.id}">
                                    <div class="row">
                                        <div class="col-md-3">
                                            <div class="form-group">
                                                <label>权限</label>
                                                <select name="power" class="form-control">
                                                    <option value="0" ${user.power == 0?"selected='select'":""}>普通管理员</option>
                                                    <option value="1" ${user.power == 1?"selected='select'":""}>超级管理员</option>
                                                </select>

                                            </div>
                                        </div>

                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label>用户名</label>
                                                <input type="text" class="form-control" id="username" placeholder="用户名"
                                                       name="username" value="${user.username}" max="20" readonly>
                                                <span id="recMsg"></span>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label>原密码</label>
                                                <input type="password" id="oldpassword" class="form-control" placeholder="原密码"
                                                       name="oldpassword" max="30" required>
                                            </div>
                                        </div>
                                    </div>


                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label>密码</label>
                                                <input type="password" id="password" class="form-control" placeholder="新密码"
                                                       name="password"  max="30" required>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label>确认密码</label>
                                                <input type="password" id="repassword" class="form-control" placeholder="确认密码"
                                                       name="repassword" max="30"  required>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label>性别</label><br>
                                                <input type="radio"   ${user.sex=="男"?"checked='checked'":""} name="sex" value="男">男&nbsp&nbsp&nbsp&nbsp
                                                <input type="radio"  ${user.sex=="女"?"checked='checked'":""} name="sex" value="女">女
                                            </div>
                                        </div>
                                    </div>
                                    <button type="submit" class="btn btn-info btn-fill pull-right">保存</button>
                                    <div class="clearfix"></div>
                                </form>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <%@include file="include/footer.jsp" %>
    </div>
</div>


</body>

<!--   Core JS Files   -->
<script src="${pageContext.request.contextPath}/js/jquery-1.10.2.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script>

<!--  Checkbox, Radio & Switch Plugins -->
<script src="${pageContext.request.contextPath}/js/bootstrap-checkbox-radio-switch.js"></script>

<!--  Charts Plugin -->
<script src="${pageContext.request.contextPath}/js/chartist.min.js"></script>

<!--  Notifications Plugin    -->
<script src="${pageContext.request.contextPath}/js/bootstrap-notify.js"></script>

<!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
<script src="${pageContext.request.contextPath}/js/light-bootstrap-dashboard.js"></script>

<!-- Light Bootstrap Table DEMO methods, don't include it in your project! -->
<script src="${pageContext.request.contextPath}/js/demo.js"></script>

</html>